package edu.nuc.write;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;

/**
 * Time    : 2023/4/2 9:52
 * Author  : 王摇摆
 * FileName: PropertiesStoreTest1.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class PropertiesStoreTest1 {
    public static void main(String[] args) {
        Properties properties = new Properties();
        OutputStream output = null;

        try {
            output = new FileOutputStream("C:\\Users\\Administrator\\Desktop\\Code\\Learn_import\\Test7\\src\\main\\resources\\jdbc1.properties");
            properties.setProperty("jdbc.driver", "com.mysql.jdbc.Driver");
            properties.setProperty("jdbc.url", "jdbc:mysql://localhost:3306/mybatis?characterEncoding=utf8");
            properties.setProperty("jdbc.username", "root");
            properties.setProperty("jdbc.password", "root");

            properties.store(output,new String("wangyaobai modified！"));
        } catch (IOException ioException) {
            ioException.printStackTrace();

        } finally {
            if (output != null) {
                try {
                    output.close();
                    System.out.println("properties1文件已经成功写入！");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
